package com.hongxun.design.bean;

import android.text.Editable;
import android.text.InputType;
import android.text.TextWatcher;
import android.util.Log;
import android.view.View;

import com.hongxun.design.bean.photopassbean.SystemTypeBean;
import com.hongxun.design.constant.Constant;
import com.hongxun.design.listeners.ListenerSet;
import com.hongxun.design.mytools.MString;

import java.util.ArrayList;

/**
 * Created by zerdoor_pc on 2016/5/9.
 * 点位设置
 */
public class SetPointInfItemBean {
    private double lat = -1;
    private double lon = -1;
    private String altitude;
    private String Name;
    private String NameCode;
    private int ItemStyle;
    private int inputType = -1;
    private String Novalue;
    private String value = "";
    private String valueCode = "";
    private String valueid = "";
    private boolean isEdit = true;
    private TextWatcher textWatcher;//
    public ArrayList<SystemTypeBean> data;//弹出框的数据
    private boolean notNull = false;
    private View.OnClickListener choiceModelListener;
    private View.OnClickListener materialListener;


    public SetPointInfItemBean(boolean isEdit, double lat, double lon,
                               String altitude, String name, int itemStyle, String novalue, String value) {
        this.lat = lat;
        this.lon = lon;
        this.altitude = altitude;
        Name = name;
        ItemStyle = itemStyle;
        Novalue = novalue;
        this.isEdit = isEdit;
        this.value = value;

    }

    public SetPointInfItemBean(boolean isEdit, String name, String NameCode,
                               int itemStyle, String novalue, String value, boolean notNull,
                               ArrayList<SystemTypeBean> data) {
        Name = name;
        this.NameCode = NameCode;
        ItemStyle = itemStyle;
        Novalue = novalue;
        this.value = value;
        if (itemStyle == Constant.EdStyle) {
            this.valueCode = value;
        }
        this.isEdit = isEdit;
        this.notNull = notNull;
        this.data = data;
        if (itemStyle == Constant.EdStyle) {
            setTextWatcher();
        }

        if (itemStyle == Constant.JumpStyle) {
            setChoiceModelListener();
            setMaterialListener();
        }
        if(itemStyle == Constant.ScanStyle){
            setTextWatcher();
        }

    }

    public SetPointInfItemBean(boolean isEdit, String name, String NameCode, int itemStyle,
                               String novalue, String value, String valueCode, boolean notNull,
                               ArrayList<SystemTypeBean> data) {
        Name = name;
        this.NameCode = NameCode;
        ItemStyle = itemStyle;
        Novalue = novalue;
        this.value = value;
        this.valueCode = valueCode;

        this.isEdit = isEdit;
        this.notNull = notNull;
        this.data = data;
        if (itemStyle == Constant.EdStyle) {
            setTextWatcher();
        }

        if (itemStyle == Constant.JumpStyle) {
            setChoiceModelListener();
            setMaterialListener();
        }
        if(itemStyle == Constant.ScanStyle){
            setTextWatcher();
        }

    }

    public SetPointInfItemBean(double lat, double lon, String altitude, String name, int itemStyle, String novalue, String value) {
        this.lat = lat;
        this.lon = lon;
        this.altitude = altitude;
        Name = name;
        ItemStyle = itemStyle;
        Novalue = novalue;

        this.value = value;

    }

    public SetPointInfItemBean(String name, String NameCode, int itemStyle, String novalue, String value, boolean notNull, ArrayList<SystemTypeBean> data, int inputType) {
        Name = name;
        ItemStyle = itemStyle;
        Novalue = novalue;
        this.NameCode = NameCode;
        this.value = value;
        this.notNull = notNull;
        this.inputType = inputType;
        if (data != null) {
            this.data = data;
        }
        if (itemStyle == Constant.EdStyle) {
            setTextWatcher();
        }
        if (itemStyle == Constant.JumpStyle) {
            setChoiceModelListener();
            setMaterialListener();
        }
        if(itemStyle == Constant.ScanStyle){
            setTextWatcher();
        }
    }

    public SetPointInfItemBean(String name, String NameCode, int itemStyle, String novalue, String value,
                               String valueCode, boolean notNull, ArrayList<SystemTypeBean> data, int inputType) {
        Name = name;
        ItemStyle = itemStyle;
        Novalue = novalue;
        this.NameCode = NameCode;
        this.value = value;
        this.valueCode = valueCode;
        this.notNull = notNull;
        this.inputType = inputType;
        if (data != null) {
            this.data = data;
        }
        if (itemStyle == Constant.EdStyle) {
            setTextWatcher();
        }
        if (itemStyle == Constant.JumpStyle) {
            setChoiceModelListener();
            setMaterialListener();
        }
        if(itemStyle == Constant.ScanStyle){
            setTextWatcher();
        }
    }

    public SetPointInfItemBean(String name, String NameCode, int itemStyle, String novalue,
                               String value, boolean notNull, ArrayList<SystemTypeBean> data) {
        Name = name;
        ItemStyle = itemStyle;
        Novalue = novalue;
        this.NameCode = NameCode;
        this.value = value;
        this.valueCode = value;
        this.notNull = notNull;

        if (data != null) {
            this.data = data;
        }
        if (itemStyle == Constant.EdStyle) {
            setTextWatcher();
        }
        if (itemStyle == Constant.JumpStyle) {
            setChoiceModelListener();
            setMaterialListener();
        }
        //new
        if (itemStyle == Constant.newStyle1) {
            setChoiceModelListener();
            setMaterialListener();
        }
        if (itemStyle == Constant.newStyle2) {
            setTextWatcher();
        }
        if(itemStyle == Constant.ScanStyle){
            setTextWatcher();
        }
    }

    public SetPointInfItemBean(String name, String NameCode, int itemStyle, String novalue,
                               String value, String valueCode, boolean notNull, ArrayList<SystemTypeBean> data) {
        Name = name;
        ItemStyle = itemStyle;
        Novalue = novalue;
        this.NameCode = NameCode;
        this.value = value;
        this.valueCode = valueCode;
        this.notNull = notNull;

        if (data != null) {
            this.data = data;
        }
        if (itemStyle == Constant.EdStyle) {
            setTextWatcher();
        }
        if (itemStyle == Constant.JumpStyle) {
            setChoiceModelListener();
            setMaterialListener();
        }
        if(itemStyle == Constant.ScanStyle){
            setTextWatcher();
        }
    }

    public void setTextWatcher() {
        TextWatcher textWatcher = new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
                Log.d("s","");
            }

            @Override
            public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
                Log.d("s","");
            }

            @Override
            public void afterTextChanged(Editable editable) {
                value = editable.toString();
                valueCode = editable.toString();
            }
        };
        this.textWatcher = textWatcher;
    }


    public String getValueid() {
        return valueid;
    }

    public void setValueid(String valueid) {
        this.valueid = valueid;
    }

    public boolean isNotNull() {
        return notNull;
    }

    public void setNotNull(boolean notNull) {
        this.notNull = notNull;
    }

    public int getInputType() {
        if (inputType == -1) inputType = InputType.TYPE_CLASS_TEXT;
        return inputType;
    }

    public void setInputType(int inputType) {
        this.inputType = inputType;
    }

    public boolean isEdit() {
        return isEdit;
    }

    public void setIsEdit(boolean isEdit) {
        this.isEdit = isEdit;
    }

    public String getValueCode() {
        return valueCode;
    }

    public void setValueCode(String valueCode) {
        this.valueCode = valueCode;
    }

    public String getNameCode() {
        return NameCode;
    }

    public void setNameCode(String nameCode) {
        NameCode = nameCode;
    }

    public View.OnClickListener getChoiceModelListener() {
        return choiceModelListener;
    }

    public void setChoiceModelListener() {
        this.choiceModelListener = ListenerSet.getDesignItemClickListener(this, MString.ChoiceModelData, null);
    }

    public View.OnClickListener getMaterialListener() {
        return materialListener;
    }

    public void setMaterialListener() {
        this.materialListener = ListenerSet.getDesignItemClickListener(this, MString.Material, valueCode);
    }


    public double getLat() {
        if ((lat + "").equals(MString.erroralt)) return 0;
        return lat;
    }

    public void setLat(double lat) {
        this.lat = lat;
    }

    public double getLon() {
        if ((lon + "").equals(MString.erroralt)) return 0;
        return lon;
    }

    public void setLon(double lon) {
        this.lon = lon;
    }

    public String getAltitude() {
        if ((altitude + "").equals(MString.erroralt)) return "0";
        return altitude;
    }

    public void setAltitude(String altitude) {
        this.altitude = altitude;
    }

    public String getName() {
        return Name;
    }

    public void setName(String name) {
        Name = name;
    }

    public int getItemStyle() {
        return ItemStyle;
    }

    public void setItemStyle(int itemStyle) {
        ItemStyle = itemStyle;
    }

    public String getNovalue() {
        return Novalue;
    }

    public void setNovalue(String novalue) {
        Novalue = novalue;
    }

    public ArrayList<SystemTypeBean> getData() {

        return data;
    }

    public void setData(ArrayList<SystemTypeBean> data) {
        this.data = data;
    }

    public TextWatcher getTextWatcher() {
        return textWatcher;
    }

    public void setTextWatcher(TextWatcher textWatcher) {
        this.textWatcher = textWatcher;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

}
